import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:full_display/common/qxp_color.dart';
import 'package:full_display/common/qxp_style.dart';
import 'package:full_display/unit/screen/screen_utility.dart';

class CloudsItem extends StatefulWidget {
  const CloudsItem({super.key});

  @override
  State<CloudsItem> createState() => _CloudsItemState();
}

class _CloudsItemState extends State<CloudsItem> {
  bool _switchValue = false;
  ScrollController _scrollController = ScrollController();
  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      scrollDirection: Axis.vertical,
      shrinkWrap: true,
      physics: BouncingScrollPhysics(),
      itemCount: 7,
      itemBuilder: (context, position) {
        return _getOddDivider(position);
      },
    );
  }

  Widget _getOddDivider(int position) {
    return Container(
      margin: EdgeInsets.fromLTRB(12.0.H, 15.0.H, 12.0.H, 15.0.H),
      padding: EdgeInsets.all(17.0.H),
      decoration: const BoxDecoration(
        color: ColorPlate.backgroundOpacity5,
        borderRadius: BorderRadius.all(Radius.circular(12.0)),
      ),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Row(
                children: [
                  Text(
                    's4-b00247fcaa57',
                    style: StandardTextStyle.textWhite16BoldStyle,
                  ),
                  Container(width: 5.0.H),
                  InkWell(
                    onTap: () {},
                    child: Text(
                      '删除',
                      style: StandardTextStyle.textBlue10Style,
                    ),
                  ),
                ],
              ),
              CupertinoSwitch(
                value: _switchValue,
                activeColor: ColorPlate.app_blue,
                trackColor: ColorPlate.white,
                //dragStartBehavior: DragStartBehavior.start,
                onChanged: (value) {
                  //重新构建页面
                  setState(() {
                    _switchValue = value;
                  });
                },
              ),
            ],
          ),
          Container(height: 8.0.H),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                '媒体个数：12',
                style: StandardTextStyle.textWhite12Op50Style,
              ),
              InkWell(
                onTap: () {},
                child: Text(
                  '查看详情 >',
                  style: StandardTextStyle.textWhite12Op50Style,
                ),
              ),
            ],
          ),
          Container(
            margin: EdgeInsets.only(top: 14.0.H),
            child: Column(
              children: [
                const Divider(
                  height: 1.0,
                  color: ColorPlate.backgroundOpacity20,
                ),
                Container(
                  margin: EdgeInsets.only(top: 14.0.H),
                  height: ((10 / 4).truncateToDouble() + 1) * 86.0.W,
                  child: GridView.builder(
                    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 4,
                        crossAxisSpacing: 12.0.W,
                        mainAxisSpacing: 12.0.W),
                    scrollDirection: Axis.vertical,
                    controller: _scrollController,
                    itemCount: 10,
                    itemBuilder: (context, index) {
                      return Container(
                        height: 74.0.W,
                        width: 74.0.W,
                        child: Text(index.toString()),
                        color: Colors.blue,
                      );
                    },
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
